$(function () {
    var swiper = new Swiper('.swiper-container', {
        spaceBetween: 30,
        centeredSlides: true,
        autoplay: {
            delay: 2500,
            disableOnInteraction: false,
        },
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
        },
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },
    });
    $(".swiper-container").hover(function () {
        $(".swiper-button-next,.swiper-button-prev").show()
    }, function () {
        $(".swiper-button-next,.swiper-button-prev").hide()
    })
    // 侧边栏转固定定位
    var wodebookrackTop = $(".wode-bookrack").offset().top;
    var wodebookrackLeft = $(".wode-bookrack").offset().left;
    wodebookrackTop = wodebookrackTop - 60
    // console.log(wodebookrackTop,wodebookrackLeft);
        $(document).on("scroll", function () {
            if (window.pageYOffset >= wodebookrackTop) {
                $(".wode-bookrack").css({
                    "position": 'fixed',
                    "top": 82,
                    "left": wodebookrackLeft,
                })
            } else {
                $(".wode-bookrack").css({
                    "position": 'absolute',
                    "top": 30,
                    "left": 850,
                })
                }
        })
    // vip榜单部分 tab 栏切换
    $(".vip-top-head ul li").mouseenter(function () {
        if ($(this).hasClass("first")) return
        $(this).addClass("mouseenter").children("a").addClass("orange")
        $(this).siblings().removeClass("mouseenter")
        $(this).siblings().children("a").removeClass("orange")
        var i = $(this).index()
        if (i == 1 || i == 0) return
        $(".vip-top-body").eq(i - 2).show().siblings().hide()
    })
    // vip榜单部分轮播图
    var index = 0
    var moreWidth = $(".vip-more").width()
    select()
    $(".right_btn").on("click", function () {
        if(index == 2) return
        index++
        $(".slide").animate({
            left: -index * moreWidth
        })
        select()
        
    })
    $(".left_btn").on("click", function () {
        if(index == 0) return
        index--
        $(".slide").animate({
            left: -index * moreWidth
        })
        select()
    })
    function select() {
        if (index == 0) {
            $(".left_btn").css({
                "cursor": "deafult",
                "opacity": .3,
            })
        } else if (index == 2) {
            $(".right_btn").css({
                "cursor": "deafult",
                "opacity": .3,
            }) 
        } else if (index == 1){
            $(".left_btn,.right_btn").css({
                "cursor": "pointer",
                "opacity": 1,
            })
        }
    }
    // 大咖部分 tab 栏切换
    $(".bigshot-hot-all").mouseenter(function () {
        $(this).children(".bigshot-hot-int").addClass("xuanzhong")
        $(this).siblings().children(".bigshot-hot-int").removeClass("xuanzhong")
        var index = $(this).index()
        var shotWidth = $(".bigshot-hot-all").children(".bigshot-hot-img").width() / 2
        var shotOuterWidth = $(".bigshot-hot-all").outerWidth(true)
        $(".triangle").stop().animate({
            "left": index * shotOuterWidth + shotWidth
        }, 300)
        $(".hot-hotbooks").eq(index).show().siblings(".hot-hotbooks").hide()
    })

    // 头部部分背景颜色和轮播图颜色相对应
    // var arr = [`#101d2d`, `#c5423e`, `#1b1b37`, `#9a88f6`, `#41270f`]
    // $(".swiper-slide").each(function (i, val) {
    //     console.log($(this).i);
    // })
})